package db_sqlite_plugin

import (
	"gorm.io/gorm"
)

const JWT_EXCLUDE_TABLE = "sys_tenant,sys_user,sys_user_dept,sys_user_post,sys_user_role,sys_user_tenant"

type QueryBeforePlugin struct{}

func (t *QueryBeforePlugin) Name() string {
	return "query_before_plugin"
}

func (t *QueryBeforePlugin) Initialize(db *gorm.DB) error {
	return db.Callback().Query().Before("gorm:query").Register("before_query", t.beforeQuery)
}

func (t *QueryBeforePlugin) beforeQuery(db *gorm.DB) {
	//tmp := db.Statement.Context.Value("jwtInfo")
	//if tmp != nil {
	//	jwtInfo := tmp.(*fw_jwt.CustomClaims)
	//	db.Statement.AddClause(clause.Where{Exprs: []clause.Expression{
	//		clause.Eq{Column: clause.Column{Table: db.Statement.Table, Name: "created_by"}, Value: jwtInfo.UserId},
	//	}})
	//}
}
